package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * desc
 *
 * @author wkh
 * @date 2024/6/12 11:12
 */
@Mapper
public interface SetmealDishMapper {
    // 根据菜品id查询套餐数量
    int getCountByDishId(List<Long> ids);

    // 新增套餐菜品关系数据
    @Insert("insert into setmeal_dish (setmeal_id, dish_id, name, price, copies) values (#{setmealId}, #{dishId}, #{name}, #{price}, #{copies})")
    void add(SetmealDish setmealDish);

    // 根据套餐id查询套餐菜品关系数据
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getBySetmealId(Long id);

    // 根据套餐id删除套餐菜品关系数据
    @Delete("delete from setmeal_dish where setmeal_id = #{id}")
    void deleteBySetmealId(Long id);

    // 根据菜品id查询套餐id
    @Select("select setmeal_id from setmeal_dish where dish_id = #{id}")
    List<Long> getSetmealIdByDishId(Long id);
}
